package com.cc.visitor.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Optional;

/**
 * @author chanchaw
 * @create 2024-09-27 10:17
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Visit implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id(keyType = KeyType.Auto)
    private Integer id;
    private String visitorOpenId;
    private String visitorUnionId;
    private String visitorMiniId;
    private String visitorNickName;
    private String visitorRealName;
    private String visitorIdNumber;
    private String visitorCompany;
    private String visitorPhone;// 访客手机号码
    private String intervieweeOpenId;
    private String intervieweeUnionId;
    private String intervieweeNickName;
    private String intervieweeRealName;
    private String intervieweeDepartment;
    private Integer userType;
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;
    private String category;
    private Integer numberOfPeople;
    private String carNumber;
    private String remark;
    private String sysRemark;
    private LocalDateTime createTime;
    private String lastUser;
    private LocalDateTime lastTime;
    private Integer isDelete;
    private Integer state;
    private String progress;
    private LocalDateTime auditTime;// 受访者审核时间
    private LocalDateTime admissionTime;// 扫描进场的时间
    private String admissionUnionId;// 展示入场二维码的微信用户 unionId
    private String qrContent;// 进场扫描的二维码的内容
    private Integer audit;// 1审核，-1驳回
    private Integer hasCar;// 1开车进场

    // 3个完工相关的字段
    private Integer finished;// 完工标识，1表示完工
    private LocalDateTime finishedTime;// 完工时间
    private String finishedUnionId;// 设置为完工状态的微信用户
    private String qrTicket;// 二维码兑换券
    private String rejectRemark;// 驳回原因
    private Integer subrogate;// 1表示代位申请制作的访单，默认0不是

    private Integer pushInteAudit;
    private Integer pushVisitAuditReject;
    private Integer pushInteEntry;
    private Integer pushInteOut;
    private String signHashString;

    public void addPushInteAudit(){
        this.pushInteAudit = this.pushInteAudit + Optional.ofNullable(this.pushInteAudit).orElse(0);
    }
    public void addPushVisitAuditReject(){
        this.pushVisitAuditReject = this.pushVisitAuditReject + Optional.ofNullable(this.pushVisitAuditReject).orElse(0);
    }
    public void addPushInteEntry(){
        this.pushInteEntry = this.pushInteEntry + Optional.ofNullable(this.pushInteEntry).orElse(0);
    }
    public void addPushInteOut(){
        this.pushInteOut = this.pushInteOut + Optional.ofNullable(this.pushInteOut).orElse(0);
    }

    // 下面两个属性对应存储过程 usp_getVisitList8DateRangeOpenId 的最后两个字段
    // 用于显示历史数据
    private String people;
    private String time;
}
